package org.testis.testdriver.parser;

import org.testis.testdriver.AtofEnumaration;
import org.testis.testdriver.ITestBuilder;
import org.orm.PersistentException;
import org.testis.orm.refinedclasses.PostConditionCaseRefined;
import org.testis.orm.refinedclasses.TestDesignTreeNode;
import org.testis.orm.refinedclasses.TestDesignTreeRefined.TestDesignTreeParameters;
import org.testis.utils.middleware.TestDesign;

/**
 *
 * @author barisergun
 */
public class TestDriverPostConditionCaseRefinedParsing extends TestDriverAbstractParsingStrategy {

    public TestDriverPostConditionCaseRefinedParsing(ITestBuilder builder,
            TestDesignTreeNode currentNode) {
        m_builder = builder;
        m_currentNode = currentNode;

        if (m_currentNode.isClone()) {
            m_cloneString = " [clone]";
        }
    }

    @Override
    public void parseCurrentNode() throws PersistentException {
        PostConditionCaseRefined testPart =
                (PostConditionCaseRefined) m_currentNode.getObject();
        m_builder.buildTestPart(String.valueOf(m_currentNode.getId()),
                testPart.getName() + m_cloneString,
                testPart.getReference().getDescription(),
                AtofEnumaration.TestPartType.PostConditionCase,
                String.valueOf(m_currentNode.getParent().getId()));
        Boolean isCritical = m_currentNode.getReference().getParameterBooleanValue(TestDesignTreeParameters.Critical.name());

        m_builder.setIsCriticalPart(String.valueOf(m_currentNode.getId()),
                isCritical.booleanValue());

    }
}
